import axios from "axios";


class Http {
  constructor() {
    this._instance = axios.create({
      timeout: process.env['REACT_APP_TIMOUT']
    })
    this.interceptor()
  }


  //响应拦截器
  interceptor() {
    this._instance.interceptors.response.use(
      res => res.data,
      err => Promise.reject(err)
    )
  }


  get(url, config = {}) {
    return this._instance.get(url, config)
  }

  post(url, data = {}, config = {}) {
    return this._instance.post(url, data, config)
  }
}

// export default new Http()
export default Http;